<?
/*Created by : G.M.Sundar 
[created : 01/18/2007, 09:53:54 AM]
 Description:
*/
function
drawPdfString($fontname="Arial",$fontstyle="",$fontsize="10",$topmargin,
$leftmargin ,
$strings,$wrapsize=25,$wrapbreak="\\n",$cellwidth=0,$cellheight=5,
$cellborder=0, $cellalign="J",$cellfill=0)
{
global $pdf;
$pdf->SetFont($fontname,$fontstyle,$fontsize);
$pdf->setY($topmargin);
$pdf->setX($leftmargin);

	if($strings)
	{
		$printdata=wordwrap($strings,$wrapsize,$wrapbreak,1);
		$pdf->MultiCell($cellwidth,$cellheight,$printdata,$cellborder,$cellalign,
		$cellfill);
	}
}

function countlines($lines,$size,$separator="\n")
{

$warptext=wordwrap($lines,$size,"$separator");
$explode_text=explode($separator,$warptext);

$cnt=count($explode_text);
return($cnt);
}
function makeString($string,$width_array)
{
$resultstring=array();
$max_line_count=array();
$formated_string=array();
// echo "<TABLE border=1>";
	if(count($string[0])!=count($width_array))
	{
		echo "Check No of Columns and width Array" ;
		exit;
	}
$i=0;	
foreach ($string as $key=>$value)
	{
	$j=0;	
// echo "<TR>";
		foreach ($value as $key1=>$value1)
			{
		 
			$warptext=wordwrap($value1,$width_array[$j],"\n",1);
			$stringarray=explode("\n",$warptext);
// 				echo "<TD $width_array[$j]>";
			$column_line_count=0;
			foreach($stringarray as $key2=>$value3)
					{
// 					str_pad($value3,$width_array[$j],"--").$width_array[$j];

			$column_line_count++;
					}
$formated_string[$i][$j]=$stringarray;
$max_line_count[$i][$j]=$column_line_count;

			$j++;
			
			}
$i++;
// echo "</TR>";	
	}

// echo "<TABLE>";
$item_max_line=array();
foreach ($max_line_count as $key=>$value)
{
sort($max_line_count[$key]);
$item_max_line[$key]=end($max_line_count[$key]);
}
$resultstring=assignStringToArray($formated_string,$item_max_line,$width_array);
return $resultstring;

}
function assignStringToArray($string,$item_max_line,$width_array)
{
$returnstring=array();

foreach($string as $key=>$value)
{
	for($j=0;$j<=($item_max_line[$key]-1);$j++)
		{

               for($i=0;$i<=(count($width_array)-1);$i++)
			{
			
			 $returnstring[$key][$j][$i]=$string[$key][$i][$j];

			}
		}
}
return $returnstring;
}
?>